package com.rabboit.config2;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/9/1  16:16
 * 描述: 消息发送到交换机的确认
 */
//@Component
public class MyConfirmCallBack implements RabbitTemplate.ConfirmCallback {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void postInit(){
        rabbitTemplate.setConfirmCallback(this);
    }

    @Override
    public void confirm(CorrelationData correlationData, boolean b, String s) {

        //System.out.println("============>"+s);

        /*if(b){
            System.out.println("==========发送交换器成功");
        }else{
            //修改本地消息表消息的状态  没有正常发送到交换机  1
            //到DB去修改
            System.out.println("-----发送失败---修改本地消息表消息的状态  没有正常发送到交换机  1-");
        }*/

    }
}
